Walkthrough 8-3: Consume a SOAP web service

In this walkthrough, you consume a Delta SOAP web service. You will:

·       Create a new flow to call the Delta SOAP web service.

·       Use a Web Service Consumer connector to consume a SOAP web service.

·       Use the Transform Message component to pass arguments to a SOAP web service.

Starting file

If you did not complete the previous walkthrough, you can get a starting file here. This file is also located in the solutions folder of the student files ZIP located in the Course Resources.

Browse the WSDL

1.     Return to the course snippets.txt file and copy the Delta SOAP web service WSDL.

2.     In Advanced REST Client, return to the tab with the learn.mulesoft request.

3.     Paste the URL and send the GET request; you should see the web service WSDL returned.

4.     Browse the WSDL; you should find references to operations listAllFlights and findFlight.

Create a new flow with an HTTP Listener connector endpoint

5.     Return to Anypoint Studio.

6.     Drag out another HTTP Listener from the Mule Palette and drop it in the canvas after the existing flows.

7.     Rename the flow to getDeltaFlights.

8.     In the Listener properties view, set the display name to GET /delta.

9.     Ensure the connector configuration is set to the existing HTTP_Listener_config.

10.  Set the path to /delta and the allowed methods to GET.

 

Add the Web Service Consumer module to the project

11.  In the Mule Palette, select Add Modules.

12.  Select the Web Service Consumer connector in the right side of the Mule Palette and drag and drop it into the left side.

13.  If you get a Select module version dialog box, select the latest version and click Add.

 

Configure the Web Service Consumer connector

14.  Return to the course snippets.txt file and copy the text for the Delta web service properties.

15.  Return to config.yaml in src/main/resources and paste the code at the end of the file.

 

Note: The Delta web service properties you see may be different than what is shown here; the values in the snippets file differ for instructor-led and self-study training classes.

16.  Save the file.

17.  Return to global.xml.

18.  Click Create.

19.  In the Choose Global Type dialog box, select Connector Configuration > Web Service Consumer Config.

 

20.  Click OK.

21.  In the Global Element Properties dialog box, change the name to Delta_Web_Service_Consumer_Config.

22.  Set the following values:

·       Wsdl location: ${delta.wsdl}

·       Service: ${delta.service}

·       Port: ${delta.port}

23.  Click OK.

Add and configure a Consume operation

24.  Return to implementation.xml.

25.  Locate the Consume operation for the Web Service Consumer connector in the Mule Palette and drag and drop it in the process section of getDeltaFilghts.

26.  In the Consume properties view, change its display name to Get flights.

27.  Ensure the connector configuration is set to the existing Delta_Web_Service_Consumer_Config.

28.  Click the operation drop-down menu; you should see the web service operations listed.

29.  Select the listAllFlights operation.

 

Review metadata associated with the Delta Get flights operation response

30.  Select the Output tab in the DataSense Explorer and expand Payload; you should see the payload structure.

 

Test the application

31.  Save the files then stop and run the project.

32.  In Advanced REST Client, return to the tab with the localhost request.

33.  Make a GET request to http://localhost:8081/delta; you should get a 200 status code and a response listing the contents of listAllFlightsResponse.

 

Transform the response to JSON

34.  Return to Anypoint Studio.

35.  Add a Transform Message component to the end of the flow.

36.  Set the display name to SOAP to JSON.

 

37.  In the Transform Message properties view, change the output type to application/json and set the expression to payload.

Test the application

38.  Save the file to redeploy the project.

39.  In Advanced REST Client, make another request to http://localhost:8081/delta; you should get JSON returned.

 

40.  Click the Toggle raw response view (or Toggle source view) button; you should see all the flights.

 

41.  Add a query parameter called code and set it equal to LAX.

42.  Send the request; you should still get all flights.

Call a different web service operation

43.  Return to getDeltaFlights in Anypoint Studio.

44.  In the properties view for Get flights Consume operation, change the operation to findFlight.

 

45.  Save all files to redeploy the application.

Review metadata associated with the Delta Get flights operation response

46.  Return to the Get flights properties view.

47.  Select the Output tab in the DataSense Explorer and expand Payload; you should now see the payload metadata for findFlightResponse.

48.  Select the Input tab and expand Payload; you should see this operation now expects a destination.

 

Test the application

49.  In Advanced REST Client, send the same request with the query parameter; you should get a 500 Server Error with a message that the operation requires input parameters.

 

Use the set airport code subflow

50.  Return to getDeltaFlights in Anypoint Studio.

51.  Add a Flow Reference component after the GET /delta Listener.

52.  In the Flow Reference properties view, set the flow name and display name to setCode.

 

Use the Transform Message component to pass a parameter to the web service

53.  Add a Transform Message component after the Flow Reference component.

54.  Change its display name to Pass code.

55.  In the Pass code properties view, look at the input and output sections.

56.  Drag the code variable in the input section to the destination element in the output section.

 

Test the application

57.  Save the file to redeploy the application.

58.  In Advanced REST Client, make another request; you should now only see flights to LAX.

 



Did you complete the walkthrough?

  Yes, I completed the walkthrough

  No, I did not complete the walkthrough

  I completed part of the walkthrough


Comments and/or feedback